import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wwy
 * Date: 2024-05-07
 * Time: 12:30
 */
//调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
//如数组：[1,2,3,4,5,6]
//调整后可能是：[1, 5, 3, 4, 2, 6]
public class TiaoXu {
    public static void main(String[] args) {
        int[] arr = {4, 5, 6, 45, 5, 6, 4, 6, 46};
        int i = 0;
        int j = arr.length - 1;
        while (i <= j) {
            if (arr[i] % 2 == 1){
                i++;
            }
            if (arr[j] % 2 == 0){
                j--;
            }
            if (arr[i] % 2 == 0 && arr[j] % 2 == 1) {
                int t = arr[i];
                arr[i] = arr[j];
                arr[j] = t;
                i++;
                j--;
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
